package boot.spring.controller;

import boot.spring.entity.Permission;
import boot.spring.entity.PermissionsModule;
import boot.spring.service.RightsmanagementService;
import boot.spring.util.Result;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/*权限模块融合页面*/
@RestController
@RequestMapping("/RightsmanagementController")
public class RightsmanagementController {
    @Autowired/*注入权限模块融合页面的业务层*/
   private RightsmanagementService rightsmanagementService;

    Result r=new Result();


    @RequestMapping("/ListPmConAll")/*权限模块融合返回*/
   public Result ListPmConAll(){
        List<PermissionsModule> permissionsModules = rightsmanagementService.ListPmSerAll();
        if(permissionsModules.size()>0){
            r=new Result(0,"请求成功",permissionsModules.size(),permissionsModules);
        }else{
            r=new Result(1,"请求失败");
        }
        return r;
   }


    /*新增权限*/
    @RequestMapping("/GetPerConAdd")
    public Result GetPerConAdd(Permission add){
        return  rightsmanagementService.GetPerSerAdd(add);
    }

    /*删除权限*/
    @RequestMapping("/GetPerConDel")
    public Result GetPerConDel(@Param(value="pid")Integer pid) {
        return  rightsmanagementService.GetPerSerDel(pid);
    }

}
